var vm_zhuanjia = new Vue({
    el: "#index",
    data: {
        deptid: $("#deptid").val(),		// deptid
        olddeptid: $("#olddeptid").val(),		// deptid
        jigoujibie: $("#jigoujibie").val(),		// deptid

        zhuanjialist: [],// 列表list
        zhanghaoxinxiList:[],//账号信息list
        zhuanjiaItem:[],//联系方式item

        bokuanjilu : [],

        zhanghuxinxi:[],//专家账户信息
        historylist : [],//变动历史

        countZhengchang:0,
        count90:0,
        count91:0,
        count92:0,
        count93:0,
        count94:0,


        //查询用字段
        zhuanjia: "",
        danwei: "",
        cengji: "",
        gongzuodanwei: "",
        ruxuannianfen: "",
        zhuanjiazhuangtai: "",
        zhuanjiazhuangtaibiandongshijian: '',

        pageindex: 1,		// 查询分页初始化页
        pagesize: 10,		// 查询分页初始化页面大小
        pageCount: 0,		// 总页数
        recordCount: 0,	// 总记录数
        targetpage: '', 	// 目标页
    },
    created: function () {
        var _this = this;

        _this.bindZhuanjiaList();

    },
    watch: {
        //监控分页情况，刷新列表
        pageindex: function () {
            this.bindZhuanjiaList();
        },

        pagesize: function () {
            this.bindZhuanjiaList();
        },
    },
    methods: {

        bindZhuanjiaList: function () {
            var _this = this;
            $.post('/system/zhuanjia/chaxuntongjilist', {
                deptid: _this.deptid,
                zhuanjia: _this.zhuanjia,
                danwei: _this.danwei,
                cengji: _this.cengji,
                gongzuodanwei : _this.gongzuodanwei,
                ruxuannianfen: _this.ruxuannianfen,
                zhuanjiazhuangtai: _this.zhuanjiazhuangtai,
                zhuanjiazhuangtaibiandongshijian: _this.zhuanjiazhuangtaibiandongshijian,
                pageindex: _this.pageindex,
                pagesize: _this.pagesize,
                rdm: Math.random()
            }, function (ppData) {
                if (ppData != null) {
                    var data = ppData.resultContent;
                    _this.zhuanjialist = data.zhuanjialist;
                    var pageInfo = data.PageInfo;
                    _this.pageindex = pageInfo.pageIndex;
                    _this.pageCount = pageInfo.pageCount;
                    _this.recordCount = pageInfo.recordCount;
                    _this.targetpage = '';

                    var countInfo = data.CountInfo;
                        _this.countZhengchang=countInfo.countzhengchang,
                        _this.count90=countInfo.count90,
                        _this.count91=countInfo.count91,
                        _this.count92=countInfo.count92,
                        _this.count93=countInfo.count93,
                        _this.count94=countInfo.count94
                }
            }, "json");
        },

        reset: function () {
            var _this = this;

                _this.zhuanjia = "",
                _this.danwei = "",
                _this.cengji = "",
                _this.gongzuodanwei = "",
                _this.ruxuannianfen = "",
                _this.zhuanjiazhuangtai = "",
                _this.zhuanjiazhuangtaibiandongshijian = "",

                _this.pageindex = 1,		// 查询分页初始化页
                _this.pagesize = 10,		// 查询分页初始化页面大小
                _this.pageCount = 0,		// 总页数
                _this.recordCount = 0,	// 总记录数
                _this.targetpage = '', 	// 目标页
             _this.bindZhuanjiaList();
        },

        Export: function () {
            var _this = this
            location.href = "/export/ZhuanjiaguanliChaxuntongji?deptid="+this.deptid
                +"&zhuanjia="+_this.zhuanjia
                +"&danwei="+_this.danwei
                +"&gongzuodanwei="+_this.gongzuodanwei
                +"&ruxuannianfen="+_this.ruxuannianfen
                +"&zhuanjiazhuangtai="+_this.zhuanjiazhuangtai
                +"&zhuanjiazhuangtaibiandongshijian="+_this.zhuanjiazhuangtaibiandongshijian
        },

        //审核记录
        showHistoryModel:function(ppZhuanjiaId){
            var _this = this;

            $("#HistoryModalLabel").html("专家状态变动审核记录");
            $("#HistoryModal").modal();

            _this.bindHistory(ppZhuanjiaId);
        },

        bindHistory:function(ppZhuanjiaId){
            var _this = this;

            $.post('/system/biandonghistory/list', {
                zhuanjiaid : ppZhuanjiaId,
                rdm : Math.random()
            },function(ppData) {
                if (ppData != null) {
                    _this.historylist = ppData.rows;
                }
            },"json");
        },

        toBokuanjilu:function (zhuanjiaitem) {
            var _this = this;

            var _this = this;
            _this.zhanghuxinxi = zhuanjiaitem

            $.post('/system/jingfeidetail/jingfeilishi', {
                zhuanjiaid: zhuanjiaitem.zhuanjiaid,
                rdm: Math.random()
            }, function (ppData) {
                if (ppData != null) {
                    var data = ppData.resultContent;
                    _this.bokuanjilu = data;
                }
            }, "json");

            $("#bokuanjiluModal").modal();
        },

        toLianxifangshi:function (zhuanjiaitem) {
            var _this = this;
            _this.zhanghuxinxi = zhuanjiaitem

            $.post('/system/deptdetail/Zhanghaoxinxi', {
                deptid: zhuanjiaitem.deptid,
                rdm: Math.random()
            }, function (ppData) {
                if (ppData != null) {
                    var data = ppData.resultContent;
                    _this.zhanghaoxinxiList = data;
                }
            }, "json");

            $("#lianxifangshiModal").modal();
        },

        toShenhejilu:function () {

        },
        getDate:function () {
            var _this = this;
            _this.zhuanjiazhuangtaibiandongshijian=$("#zhuanjiazhuangtaibiandongshijian").val();
        },

        //首页
        firstPage: function () {
            this.pageindex = 1;
        },
        //尾页
        lastPage: function () {
            this.pageindex = this.pageCount;
        },
        //上一页
        prePage: function () {
            var prePage = ((this.pageindex - 1) <= 0) ? 1 : (this.pageindex - 1);
            this.pageindex = prePage;
        },
        //下一页
        nextPage: function () {
            var nextPage = ((this.pageindex + 1) >= this.pageCount) ? this.pageCount : (this.pageindex + 1);
            this.pageindex = nextPage;
        },
        //跳到目标页
        targetPage: function () {
            if (this.targetpage != '' && this.targetpage <= this.pageCount && this.targetpage > 0) {
                this.pageindex = this.targetpage;
                this.targetpage = '';
            }
        },

    },
})